home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / src / tools / mailid.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  810 b   |  42 lines

  1. /*
  2.  *    M A I L I D . C
  3.  *
  4.  *    This program is designed to be used by other programs and/or
  5.  *    shell scripts to obtain the mail id for a given person.
  6.  *    If no userid is give, the userid of the current real uid
  7.  *    is assumed.
  8.  */
  9. #include <stdio.h>
  10. #include <pwd.h>
  11.  
  12. main (argc, argv)
  13. int    argc;
  14. char    **argv;
  15. {
  16.     register char *user;
  17.     register char *mailid;
  18.     char *getmailid();
  19.  
  20.     mmdf_init(argv[0]);
  21.     if (argc < 2) {
  22.         register struct passwd *pw;
  23.         struct passwd *getpwuid();
  24.  
  25.         if ((pw = getpwuid (getuid())) == NULL) {
  26.             fprintf (stderr, "prmailid: No user with uid %d.\n",
  27.                  getuid());
  28.             exit (9);
  29.         }
  30.         user = pw->pw_name;
  31.     } else
  32.         user = argv[1];
  33.  
  34.     if ((mailid = getmailid(user)) == NULL) {
  35.         fprintf (stderr, "prmailid: No mailid for user '%s'.\n",
  36.              user);
  37.         exit (8);
  38.     }
  39.     puts(mailid);
  40.     exit (0);
  41. }
  42.